package com.suo.adapter;

import com.utils.BitmapUtil;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

@SuppressWarnings("deprecation")
public class MyGalleryAdapter extends BaseAdapter {

	private Context context;
	private int[] pic;
	public MyGalleryAdapter(Context context, int[] pic) {
		this.context = context;
		this.pic = pic;
	}

	@Override
	public int getCount() {
		
		return pic.length;
	}

	@Override
	public Object getItem(int arg0) {
		
		return pic[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		ImageView i = new ImageView(this.context);  
        i.setImageBitmap(BitmapUtil.readBitmap(context, pic[arg0])); 
        i.setScaleType(ImageView.ScaleType.FIT_XY);  
        i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));  
        return i;  
	}

}
